<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
</body>
<script>
  let arr = [1,2,4,5,3,5,2]
  function setArr(arr) {
    let newArr = []
    for(let i=0; i<arr.length; i++) {
      newArr.indexOf(arr[i]) === -1 ? newArr.push(arr[i]) : newArr
    }
    return newArr
    
    // arr = arr.sort()
    // for(let i=0; i<arr.length;i++) {
    //   arr[i] === arr[i-1] ? newArr : newArr.push(arr[i])
    // }
    // return newArr
  }
  console.log(setArr(arr));
  // let newArr = arr.sort()
  // （1）
  // let newArr = new Set(arr)
  // console.log(newArr)


  // Promise.prototype.all = (arr) => {
  //   let result = []
  //   let current = 0
  //   let arrLength = arr.length
  //   return new Promise((reslove, reject) => {
  //     for(let val of arr) {
  //       Promise.resolve(val).then(res => {
  //         current++
  //         result[i] = res
  //         if (arrLength === current) {
  //           return reslove(reslove)
  //         }
  //       }, (error) => {
  //         return reject(error)
  //       })
  //     }
  //   })
  // }
  // let promiseAll = Promise.all([promise1, promise2, promise3])
  // promiseAll.then(res => {
  //   console.log(res)
  // })
</script>
</html>